package com.fish.controller;

import com.fish.common.result.Result;
import com.fish.model.vo.DashboardVO;
import com.fish.model.vo.UserStatisticsVO;
import com.fish.service.DashboardService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 仪表盘控制器
 */
@RestController
@RequestMapping("/api/dashboard")
@RequiredArgsConstructor
@Tag(name = "仪表盘管理", description = "仪表盘相关接口")
public class DashboardController {

    private final DashboardService dashboardService;

    /**
     * 获取仪表盘统计数据
     *
     * @return 仪表盘数据
     */
    @GetMapping("/data")
    @Operation(summary = "获取仪表盘统计数据", description = "获取系统的各项统计数据")
    public Result<DashboardVO> getDashboardData() {
        DashboardVO dashboardData = dashboardService.getDashboardData();
        return Result.success(dashboardData);
    }

    /**
     * 获取用户注册统计
     *
     * @return 用户统计列表
     */
    @GetMapping("/user-statistics")
    @Operation(summary = "获取用户注册统计", description = "获取最近7天的用户注册统计数据")
    public Result<List<UserStatisticsVO>> getUserStatistics() {
        List<UserStatisticsVO> statistics = dashboardService.getUserStatistics();
        return Result.success(statistics);
    }
}

